local wangzhemengxiang = fk.CreateSkill {
  name = "wangzhemengxiang",
  tags = { Skill.Wake },
}

Fk:loadTranslationTable{
  ["wangzhemengxiang"] = "王者梦想",
  [":wangzhemengxiang"] = "觉醒技，你的第二个回合开始时，你令所有梦之队势力玩家获得技能【梦影】。",
}

wangzhemengxiang:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(wangzhemengxiang.name) and player.phase == Player.Start and
      player:usedSkillTimes(wangzhemengxiang.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    local turn_events = player.room.logic:getEventsOfScope(GameEvent.Turn, 2, function (e)
        return e.data.who == player
      end, Player.HistoryGame)
      return #turn_events == 2 and turn_events[2].data == data
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room:getAlivePlayers()) do
      -- 为每个存活玩家添加 "n_fenliang" 技能
      -- 第三个参数 nil 表示不指定技能的额外参数，第四个参数 false 表示不是临时添加技能
      if p.kingdom == "dream" then
        -- 指示目标玩家指向额外目标
        room:handleAddLoseSkills(p, "mengyingmizong")
     end
    end
  end,
})

return wangzhemengxiang
